package org.product.chat.entity;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * @author zqx
 * @date 2020-12-22
 */
public class Message {
    /**
     * 欢迎信息
     */
    private String info ;
    /**
     * 聊天信息
     */
    private String message ;
    /**
     * 发送目标
     */
    private String to ;
    /**
     * 聊天类型：1私聊，2群聊
     */
    private Integer type ;
    /**
     * 群聊用户列表
     */
    private List<String> userList ;

    public String getInfo() {
        return info;
    }

    public void setInfo(String info) {
        this.info = info;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String username,String message) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss") ;
        StringBuilder sb = new StringBuilder() ;

        if(this.type==1) {
            sb.append("<b style='color:green'>[群聊]</b>&nbsp;") ;
        } else {
            sb.append("<b style='color:red'>[私聊]</b>&nbsp;") ;
        }

        sb.append(username).append(" ").append(sdf.format(new Date())).append("<br/>").append(message).append("<br/>") ;
        this.message = sb.toString() ;
    }

    public String getTo() {
        return to;
    }

    public void setTo(String to) {
        this.to = to;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public List<String> getUserList() {
        return userList;
    }

    public void setUserList(List<String> userList) {
        this.userList = userList;
    }
}
